package com.edfu.core.coursemgt.persistence.entity;

import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;




/**
 * 
 * @author sahsharm
 *This class represents lecture, lab etc which are associated with a given course instance
 *For example class for  ADBMS Course for Computer Science Batch - 2009
 */
@Entity
@Table(name="class", uniqueConstraints=@UniqueConstraint(columnNames={"course_inst_id", "name"}))
public class ClassEntity implements ICourseMgtEntity {
	private long id;
	private CourseOfferingInstanceEntity course;
	private String category;
	private String title;
	private String description;
	private Set<MeetingEntity> meetings;
	private Date date;
	private String name;
	
	public Date getDate() {
		return date;
	}
	public void setDate(Date date) {
		this.date = date;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	
	@ManyToOne(cascade=CascadeType.ALL)
	@JoinColumn(name = "course_inst_id", nullable = true)
	public CourseOfferingInstanceEntity getCourse() {
		return course;
	}
	public void setCourse(CourseOfferingInstanceEntity course) {
		this.course = course;
	}
	public String getCategory() {
		return category;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public void setCategory(String category) {
		this.category = category;
	}
	
	@OneToMany(mappedBy = "klass", fetch= FetchType.EAGER)
	public Set<MeetingEntity> getMeetings() {
		return meetings;
	}
	public void setMeetings(Set<MeetingEntity> meetings) {
		this.meetings = meetings;
	}
	
}
